//
//  StatusForwardCell.swift
//  Tanenbaum_blog
//
//  Created by Tanenbaum on 15/8/3.
//  Copyright © 2015年 GZJ. All rights reserved.
//

import UIKit

class StatusForwardCell: StatusCell {

  override var status: Status? {
        didSet {
            
            let name = status?.retweeted_status?.user?.name ?? ""
            let text = status?.retweeted_status?.text ?? ""
            
            forwardLabel.text = "@" + name + ":" + text
        }
    }
    
    
    override func setupUI() {
       
        super.setupUI()
        
        //添加控件视图
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(forwardLabel, aboveSubview: backButton)
        
        forwardLabel.text = "就算生活步步紧逼，情节节节败退，我们也勉强交手几个回合，这世界才虚晃几枪呢，我们干嘛要掉头就走啊"
        
        //添加约束
        //1、添加转发背景
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -satusCellControlMargin, y: satusCellControlMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        //2、添加文本约束
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: satusCellControlMargin, y: satusCellControlMargin))
        // 3 图片视图
        let con =  pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: satusCellControlMargin))
        pictureWidthCons = pictureView.ff_Constraint(con, attribute: NSLayoutAttribute.Width)
        pictureHeightCons = pictureView.ff_Constraint(con, attribute: NSLayoutAttribute.Height)
        pictureTopCons = pictureView.ff_Constraint(con, attribute: NSLayoutAttribute.Top)
    }
    
    
    //MARK  -- 懒加载
    
    private lazy var forwardLabel: UILabel = {
       
        let label = UILabel(color: UIColor.darkGrayColor(), fontSize: 14)
        
        label.numberOfLines = 0
        label.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * satusCellControlMargin
        
        return label
    }()
    
    private lazy var backButton: UIButton = {
        
        let button = UIButton()
         button.backgroundColor = UIColor(white: 0.92, alpha: 1.0)
        
        return button
    }()
}
